<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<f:metadata>
		<f:event listener="#{AygitYazilimlariBean.verifyProducer}" type="preRenderView" />
	</f:metadata>
</h:head>
<h:body>
	<ui:composition template="template.xhtml">

		<ui:define name="title">mehmet emmy</ui:define>
		<ui:define name="body">
			<c:if test="${sessionScope.currentKullanici.grup != 2}">
				<script language="javascript">
                    	alert("bu sayfaya erişim yetkiniz yoktur.")
    					redirectPage();
	  	 			</script>
			</c:if>	
			<h:form id="yazilimIslemForm" enctype="multipart/form-data">
				<p:growl id="msgs" showDetail="true"/>
				<c:choose>
					<c:when test="${AygitYazilimlariBean.yzlIslem &amp;&amp; 
					AygitYazilimlariBean.selectedAygitYzl !=null &amp;&amp; 
					AygitYazilimlariBean.selectedAygitYzl.sirketprofil.firmaid==SirketprofilBean.currentSirketpro.firmaid}">
						
						<p:commandButton id="backButton" value="Geri Dön"
							icon="ui-icon-search"
							actionListener="#{AygitYazilimlariBean.yazilimIslem(false)}"
							update=":yazilimIslemForm" />

						<p:panel header="Yazılım Detayları">
							<h:panelGrid columns="2" id="grid">
								<h:outputLabel value="Firma : " for="firmaAd"
									style="width:100px;" />
								<h:outputLabel id="firmaAd"
									value="#{AygitYazilimlariBean.selectedAygitYzl.sirketprofil.firmaAd}" />
								
								<h:outputLabel />
								<p:separator style="width:100%; color:red;" />
								
                            	<h:outputLabel value="Ürün" />								
                            	<p:selectOneMenu value="#{AygitYazilimlariBean.selectedAygitYzl.aygit}" 
									converter="AygitConverter" 
                         			effect="fade" var="a">  
            						
            						<f:selectItems value="#{AygitBean.aygitList}" 
	            						var="aygit" itemLabel="#{aygit.model}" itemValue="#{aygit}" />                				 
  
						            <p:column>  
    	            					#{a.marka} - #{a.model}
        	    					</p:column>  
        						</p:selectOneMenu>
                            	
								<h:outputLabel />
								<p:separator style="width:100%;" />

								<h:outputLabel value="Tarih : " for="tarih" style="width:100px;"/>
								<h:inputText value="#{AygitYazilimlariBean.selectedAygitYzl.uploadTarihi}"/>								
								
								<h:outputLabel />
								<p:separator style="width:100%;" />

								<h:outputLabel value="Versiyon : " for="versiyon"
									style="width:100px;" />
								<h:inputText id="versiyon"
									value="#{AygitYazilimlariBean.selectedAygitYzl.versiyonNo}" />
								
								<h:outputLabel />
								<p:separator style="width:100%;" />

								<h:outputLabel value="Açıklama : " for="aciklama"
									style="width:100px;"/>
								<h:inputText id="aciklama"
									value="#{AygitYazilimlariBean.selectedAygitYzl.aciklama}" />
								
								<h:outputLabel />
								<p:separator style="width:100%;" />
								
								<h:outputLabel />
								<c:choose>
									<c:when test="#{AygitYazilimlariBean.yeniYzl}">
										<p:fileUpload value="#{AygitYazilimlariBean.file}" mode="simple"
										required="true" requiredMessage="Yazılım Seçilmedi..."/>
									</c:when>
									<c:otherwise>
										<p:fileUpload value="#{AygitYazilimlariBean.file}" mode="simple"/>
									</c:otherwise>
								</c:choose>
								  
								
								<h:outputLabel/>		
								<p:commandButton value="Save" ajax="false"
									action="#{AygitYazilimlariBean.yazilimIslem(false)}"
									actionListener="#{AygitYazilimlariBean.handleFileUpload}" 
									update=":yazilimIslemForm" />
							</h:panelGrid>	
						</p:panel>
					</c:when>
					<c:otherwise>

						<p:dataTable id="yzlAramaTable" var="yazilim"
							value="#{AygitYazilimlariBean.aygitYazilimList}"
							widgetVar="yazilimlarTable" resizableColumns="true"
							emptyMessage="No software found with given criteria"
							rowKey="#{yazilim.aygitYazid}"
							selection="#{AygitYazilimlariBean.selectedAygitYzl}"
							selectionMode="single" paginator="true" rows="10"
							liveScroll="true">

							<f:facet name="header">
								<p:outputPanel>
									<h:outputText value="Search all fields:" />
									<p:inputText id="globalFilter"
										onkeyup="yazilimlarTable.filter()" style="width:150px" />
								</p:outputPanel>
							</f:facet>

							<p:column id="firmaAdColumn"
								filterBy="#{yazilim.sirketprofil.firmaAd}" headerText="Firma"
								footerText="contains" filterMatchMode="contains">
								<h:outputText value="#{yazilim.sirketprofil.firmaAd}" />
							</p:column>
							<p:column id="aygtTurColumn"
								filterBy="#{yazilim.aygit.marka} - #{yazilim.aygit.model}"
								headerText="Marka-Model" footerText="contains"
								filterMatchMode="contains">
								<h:outputText id="marka-model"
									value="#{yazilim.aygit.marka} - #{yazilim.aygit.model}" />
							</p:column>

							<p:column id="upTarihColumn" filterBy="#{yazilim.uploadTarihi}"
								headerText="Upload Tarihi" footerText="contains"
								filterMatchMode="contains">
								<h:outputText value="#{yazilim.uploadTarihi}" />
							</p:column>

							<p:column id="versiyonColumn" filterBy="#{yazilim.versiyonNo}"
								headerText="Versiyon" footerText="contains"
								filterMatchMode="contains">
								<h:outputText value="#{yazilim.versiyonNo}" />
							</p:column>

							<f:facet name="footer">
								<p:commandButton id="editButton" value="Edit"
									icon="ui-icon-pencil"
									action="#{AygitYazilimlariBean.yazilimIslem(true)}"
									actionListener="#{AygitBean.getUreticiAygitlari(SirketprofilBean.currentSirketpro)}"
									update=":yazilimIslemForm" />
							</f:facet>
							<f:facet name="footer">
								<p:commandButton id="deleteButton" value="Delete"
									icon="ui-icon-trash"
									actionListener="#{AygitYazilimlariBean.deleteView}"
									update=":yazilimIslemForm" />
							</f:facet>
							<f:facet name="footer">
								<p:commandButton id="newButton" value="Add New"
									icon="ui-icon-document"
									action="#{AygitYazilimlariBean.viewNew}" 
									update=":yazilimIslemForm"/>
							</f:facet>
						</p:dataTable>

					</c:otherwise>
				</c:choose>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>